<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title><?php echo $conf['APP_NAME'];?></title>
	<link rel="stylesheet" href="./css/style.css">
</head>
<body>
	<div class="content">
		<div class="header">
			<h1><i class="icon iconfont icon-max">&#xe68f;</i> 文件管理</h1>
		</div>
		<div class="nav">
				<form action="./index.php">
					<span><i class="icon iconfont icon-mid">&#xe614;</i>路径 :</span>
					<input type="text" value="<?php echo $nowPath; ?>" name="path"> 
					<button type="submit" class="btn btn-danger">确认<i class="icon iconfont icon-min">&#xe6f1;</i></button>
					<!-- <input type="submit" class="btn btn-danger" value="确认"> -->
					<a class="btn btn-warning" href="<?php echo $prevUrl; ?>">上一级<i class="icon iconfont icon-min">&#xe682;</i></a>
				</form>
				<form action="<?php echo create_url('dir','upload',param('path') | $GLOBALS['root_path']); ?>" id="uploadform" method="post" enctype="multipart/form-data">
					<a href="javascript:;" title="上传文件到当前目录" class="file btn btn-success"><i class="icon iconfont icon-min">&#xe630;</i> 上传文件<input id="upload" type="file" name="file"></a>
				</form>
				<a class="btn btn-info" href="<?php echo $rootpath; ?>"><i class="icon iconfont icon-min">&#xe702;</i> 根目录</a>
		</div>
		<div class="filelist">
			<table class="table">
				<thead>
					<tr>
						<th>权限</th>
						<th>文件(夹)名</th>
						<th>文件后缀</th>
						<th>文件大小</th>
						<th>修改时间</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<?php
						//错误输出
						if(!empty($error_msg)){
							?>
						<tr>
							<td colspan="7">
								<ul>
								<?php
									foreach($error_msg as $v){
										?>
									<li><?php echo $v; ?></li>
										<?php
									}
								 ?>
							 	</ul>
							</td>
						</tr>
							<?php
						}
						//文件夹
							if(!empty($data['dir'])){
								foreach($data['dir'] as $v){
								?>
							<tr>
								<td>[<?php echo $v['chmod']; ?>]</td>
								<td><a href="<?php echo $v['openurl']; ?>"><i class="icon iconfont icon-mid">&#xe62e;&nbsp;</i>&nbsp;<?php echo $v['dirname']; ?></a></td>
								<td align="center">-</td>
								<td align="center">-</td>
								<td align="center">-</td>
								<td align="center">-</td>
								<td>
									<a href="<?php echo create_url('dir','rename',$v['filePath']); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe642;</i> 命名</a>
									<a href="" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe66f;</i> 压缩</a>
								</td>
							</tr>	
								<?php
								}
							}
							if(!empty($data['file'])){
								foreach($data['file'] as $v){
								?>
								<tr>
								<td>[<?php echo $v['chmod']; ?>]</td>
								<td><i class="icon iconfont icon-mid">&#xe6a3;&nbsp;</i><a href="<?php echo $v['download'] ?>"><?php echo $v['filename']; ?></a></td>
								<td align="center"><?php echo $v['suffix']; ?></td>
								<td align="center"><?php echo $v['fileSize'];?></td>
								<td align="center"><?php echo $v['filemtime'];?></td>
								<td align="center"><?php echo $v['filectime'];?></td>
								<td>
									<a href="<?php echo create_url('file','unlink',['path'=>$v['filePath']]); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe609;</i> 删除</a>
									<a href="<?php echo create_url('file','rename',['path'=>$v['filePath']]); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe642;</i> 命名</a>
									<?php
										if(!empty($v['viewedit'])){
										?>
										<a href="<?php echo create_url('file','edit',$v['filePath']); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe6d1;</i> 修改</a>
										<a href="<?php echo create_url('file','view',$v['filePath']); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe7b2;</i> 查看</a>
										<?php
										}
										if(!empty($v['zip'])){
										?>
										<a href="<?php echo create_url('file','zip',$v['filePath']); ?>" class="btn btn-danger btn-xs"><i class="icon iconfont icon-min">&#xe63c;</i> 解压</a>
										<?php
										}
									?>
								</td>
								</tr>
								<?php
								}
							}	
					?>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="7">文件:<span><?php echo $data['filenum']; ?></span>个,文件夹:<span><?php echo $data['dirnum']; ?></span>个。</td>
					</tr>
				</tfoot></table>
		</div>
		<div class="copy">
			联系我:<a href="mailto:myhonour@jishuwan.com">EMAIL</a> <br> <a href="http://www.jishuwan.com">www.jishuwan.com</a>
		</div>
	</div>
	<script>
		window.onload = function(){
			var upload = document.getElementById('upload');
			var form = document.getElementById('uploadform');
			upload.onchange = function(){
				form.submit();
			}
		}
	</script>
</body>
</html>